<?php
import('miho.event.*');

class EventDispatcher {
	private $_listeners=array();
	public function addEventListener($eventType,EventListener $listener){
		if (!isset($this->_listeners[$eventType])){
			$this->_listeners[$eventType] = array();
		}
		array_push($this->_listeners[$eventType],$listener);
	}
	
	public function dispatchEvent(Event $event){
		if (isset($this->_listeners[$event->getType()])){
			$type = $event->getType();
			if (is_array($this->_listeners[$type])){
				foreach ($this->_listeners[$type] as $listener){
					$listener->listen($event);
				}
			}
		}
	}
}

?>